//// *********************************************************
// Building class. To create a building, simply create the variable as follows:
//building buildingName(Building's object id, building's life, building model name, building texture id, building size (reccomend 100 or more),
//x coordinage, y coordinate );
// *********************************************************



#pragma once
#include <string>
using namespace std;
#ifndef BUILDING_H
#define BUILDING_H
class building{
	int id;
	int life;
	char * model;
	int texture;
	int size;
	int xPos;
	int zPos;

public:
	building();
	building(int i, int l, char * m,int t, int s,  int x, int z);
	void destroyBuilding();
	void decreaseLife(int l);
	void newBuilding();

};
#endif


#include "DarkGDK.h"
#include <string>
//#include <cstring>
//#include <cctype>
using namespace std;

//Default const.

building::building()
{
	id = 0;
	life = 0;
	model = NULL;
	texture = 0;
	size = 0;
	xPos = 0;
	zPos = 0;
	


}
//Constructor. Is passed values for building's id, life,  model, texture id, size, and x and z coordinates
building::building(int i, int l, char * m, int t, int s,  int x, int z)
{
	id = i;
	life = l;
	model = m;
	texture = t;
	size = s;
	xPos = x;
	zPos = z;
	newBuilding();


}
//Creates the building.
void building::newBuilding(){
	
	//int temp=model.size();
	//char model
	//calls a method to get model's filename. Has not been written yet. Using a dummy variable for now.
	
	////char temp = new char [model.size()+1];
//  strcpy (temp, model.c_str());
	
  //if (temp != NULL){
	dbLoadObject( model ,id );
	dbPositionObject(id, xPos, 0,zPos);
	dbScaleObject(id, size, size, size);
	//dbColorObject ( id, dbRgb ( dbRnd ( 255 ), dbRnd ( 255 ), dbRnd ( 255 ) ) );
		dbTextureObject(id, texture);
  //}

}

//destroy the building
void building::destroyBuilding(){
	dbDeleteObject(id);
}

//decrease their life
void building::decreaseLife(int l){
	life = life - l;
	if(life <= 0){
		destroyBuilding();
	}

}
